
import { IOneCampDataType } from '../FightProcess';
import CampBase from '../Camp/CampBase';
/*
 * @features: 功能
 * @description: 说明
 * @Date: 2020-08-17 10:24:21
 * @Author: judu233(769471424@qq.com)
 * @LastEditTime: 2021-09-12 15:41:16
 * @LastEditors: judu233
 */

const { ccclass, property } = cc._decorator;

/**卡牌阵营 */
export enum ECamp {
    /**基类 */
    CampBase = `CampBase`,
    /**玩家阵营 */
    Player = `Player`,
    /**电脑阵营 */
    Computer = `Computer`,
}


/**  
    * @Title : 阵营管理
    * @Description : 类说明
 **/
@ccclass
export default class CampManager extends cc.Component {

    @property([CampBase])
    public campList: CampBase[] = [];

    /**存储所有阵营的Map */
    public campMap: Map<ECamp, CampBase> = new Map();

    /******关于阵营的操作*********** */
    /**初始化阵营 */
    public initAllCamp(dataList: IOneCampDataType[]) {
        //存储阵营信息
        for (let [index, camp] of this.campList.entries()) {
            //初始化阵营信息
            camp.initCamp(dataList[index].cardData, dataList[index].campData);
            //存储阵营
            this.campMap.set(camp.camp, camp);
        }
    }

    /**根据阵营名字获取阵营 */
    public getCampByName(camp: ECamp) {
        return this.campMap.get(camp);
    }
    
    /**获取先手方 */
    public getFirstCamp() {
        return this.campMap.get(ECamp.Player);
    }

    /**获取后手方 */
    public getLastCamp() {
        return this.campMap.get(ECamp.Computer);
    }
}
